package com.api.shopapi.mapper;

import com.api.shopapi.entity.DishesPlanNight;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper
public interface DishesPlanNightMapper {


    @Insert("insert into dishes_plan_night" +
            "(" +
            "DishesPlanNightCode," +
            "DishesPlanCode" +
            ") " +
            "values" +
            "(" +
            "#{dishesPlanNight.DishesPlanNightCode}," +
            "#{dishesPlanNight.DishesPlanCode}" +
            ")")
    int insert(@Param("dishesPlanNight") DishesPlanNight dishesPlanNight);

    @Delete("delete from dishes_plan_night where dishesPlanNightCode=#{dishesPlanNightCode}")
    int delete(@Param("dishesPlanNightCode") String dishesPlanNightCode);

    @Update("update dishes_plan_night" +
            " set" +
            " DishesPlanCode=#{dishesPlanNight.DishesPlanCode}" +
            " where " +
            " dishesPlanNightCode=#{dishesPlanNight.dishesPlanNightCode}")
    int update(@Param("dishesPlanNight") DishesPlanNight dishesPlanNight);

    @Select("select * from dishes_plan_night where dishesPlanNightCode=#{dishesPlanNightCode} limit 1")
    DishesPlanNight getByDishesPlanNightCode(@Param("dishesPlanNightCode") String dishesPlanNightCode);

    @Select("<script>" +
            "select * from dishes_plan_night where dishesPlanCode=#{dishesPlanCode} " +
            "</script>")
    List<DishesPlanNight> ListByDishesPlanCode(@Param("dishesPlanCode") String dishesPlanCode);

}
